package com.da.javatest.leetCode;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author chenlida
 * @date 2019/1/14 17:44
 * @description
 */
public class Code973 {
    public int[][] kClosest(int[][] points, int K) {
        List<Integer> l1 = new ArrayList<>();
        List<Integer> l2 = new ArrayList<>();
        int[][] result = new int[K][2];
        for (int i = 0; i < points.length; i++) {
            l1.add(points[i][0] * points[i][0] + points[i][1] * points[i][1]);
            l2.add(l1.get(i));
        }
        Collections.sort(l1);
        System.out.println(l1);
        System.out.println(l2);
        for (int i = 0; i < K; i++) {
            int flag = l2.indexOf(l1.get(i));
            result[i] = points[flag];
        }
        return result;
    }
}
